package com.inossem.warehousemanage_tv.utils;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;

import com.inossem.warehousemanage_tv.constant.UrlConstant;

/**
 * Utils
 *
 * @author 詹建宇
 * @time on 2019/2/16 17:22
 * @email jianyu.zhan@inossem.com
 */
public class Utils {

    public static void closeSoftKeyboard(View view) {
        InputMethodManager inputMethodManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    public static void setText(TextView textView, String txt) {
        if (null == textView) return;
        if (TextUtils.isEmpty(txt)) {
            textView.setText("-\t-");
        } else {
            textView.setText(txt);
        }
    }

    public static String showImg(String url) {
        url = url.replace("_", "/");
        return UrlConstant.DEFAULT_HTTP
                + UrlConstant.DEFAULT_DOMAIN + ":"
                + UrlConstant.DEFAULT_PORT
                + UrlConstant.IMG_PATH
                + url;
    }

}
